// 创建用户相关仓库
import { anyRoute, asnycRoute, constantRoute } from "@/router/routes"
import { UserState } from "@/types/store"
import { defineStore } from "pinia"
import router from "@/router"


const useUserStore = defineStore("UserStore",{
    state: ():UserState =>{
       return {
        token:'',
        username:'',
        menuList: [ ...asnycRoute,anyRoute]
       }
    },
    // 逻辑，异步操作
    actions:{
    
        // 动态生成路由
        genRoutes(){
           this.menuList.forEach(route=>{
                router.addRoute(route)
            })
        }
    }
})
export default useUserStore